package com.itheima.ydd.controller;

import com.itheima.ydd.entity.Result;
import com.itheima.ydd.entity.SysConfig;
import com.itheima.ydd.service.SysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Wang.XL
 * <p>
 * 配置数据
 */
@RestController
@RequestMapping("sys_config")
@Slf4j
public class SysConfigController {

    @Autowired
    private SysConfigService service;

    /**
     * @return
     */
    @GetMapping("all")
    public Result allConfig() {
        return service.allConfig();
    }

    /**
     * 多条数据更新
     *
     * @param sysConfig
     * @return
     */
    @PostMapping(value = "update", produces = {"application/json;charset=UTF-8"})
    public Result updateConfig(@RequestBody List<SysConfig> sysConfig) {
        boolean falg = service.updateBatchById(sysConfig);
        return new Result(0, falg ? "修改成功" : "修改失败");
    }
}
